import { get } from 'lodash';
import Cookie from 'js-cookie';
import request from '../api/request';


export const geterrormessage = (error) =>
  // 目标对象 获取路径 默认值
  get(error, 'response.data.errormessage', error.message);


export const myconsole = (str) => {
  console.log(str);
  console.log(str);
  console.log(str);
  console.log(str);
  console.log(str);
  console.log(str);
  console.log(str);
};

export const mymixin = {
  created() {
    this.hello();
  },
  data() {
    return {
      message: '123',
      bar: '123',
    };
  },
  methods: {
    hello() {
      console.log('hello from mixin!');
    },
  },
};

// export const Cookies2 = Cookie.noConflict();


export const cookieSetting = function () {
  Object.assign(Cookie.defaults, { expires: 7 });
};

export const doAuth = function () {
  const token = Cookie.get('token');
  return token && token.length > 0;
};

export const testRequest = function () {
  // const myInterceptors = request.interceptors.request.use(config => {
  //   console.error('i am testRequest')
  //   return config
  // })
  // console.log(myInterceptors)
  // return myInterceptors
  const abc = request.interceptors.request.use((config) => {
    console.error('i am testRequest');
    return config;
  });
  request.interceptors.request.eject(abc);
};

// const myInterceptors = request.interceptors.request.use(config => {
//   console.error('i am testRequest')
//   return config
// })
